using System;
using Science.Mathematics;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter32
{
	/// <summary>
	/// Example02: Calculating Inductance and emf 
	/// (A)	Calculate the inductance of an air-core solenoid 
	/// containing 300 turns if the length of the solenoid is 
	/// 25.0 cm and its cross-sectional area is 4.00 cm^2. 
	/// (B)	Calculate the self-induced emf in the solenoid if 
	/// the current it carries is decreasing at the rate of 
	/// 50.0 A/s. 
	/// </summary>
	public class Example02
	{
		public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricCurrent I = new L.ElectricCurrent();
			I.A = 1.0;
			L.MagneticFlux Phi = new L.MagneticFlux();
			Phi.Wb = 4.0E-4*L.Constant.PermeabilityOfFreeSpace
				*300.0/0.25*I.A;
			L.Inductance LL = new L.Inductance(Phi,I);
			LL.NumberOfTurns = 300;
			//(A)
			result+=Convert.ToString(LL.H)+"\r\n";
			//(B)
			L.Scalar.FunctionOfTime func = new L.Scalar.FunctionOfTime(Cur);
			L.ElectricCurrent I2 = new L.ElectricCurrent();
            I2.ScalarFunctionOfTime = func;
			L.Time t = new L.Time();
			t.s = 1.0;
			L.ElectricPotentialDifference Emf 
				= new L.ElectricPotentialDifference(LL,I2,t);
			result+=Convert.ToString(Emf.V);
		}
		private L.Scalar Cur(L.Time t)
		{
            L.Scalar s = new L.Scalar();
			s.Magnitude = 50.0*t.s;
            return s;
		}
	}
}
